import http from '../../api/http.js'
import {
  requestData
} from '../../common/js/commont.js'
// 获取用户设备接收参数
const getSortData = (data) => http.post('api/device/getDeviceParams', requestData(data))
// 获取设备历史数据
const getHistorydeviceLog = (data) => http.post('/api/Devicelog/getHistoryDeviceLog', requestData(data))

const syzModules = {
  state: {
    sortData: null,
    historyData: null
  },
  mutations: {
    setSortData (state, data) {
      state.sortData = data
    },
    setHistoryData (state, data) {
      state.historyData = data
    }
  },
  actions: {
    async getPointSortData ({
      commit
    }, data) {
      try {
        const res = await getSortData(data)
        commit('setSortData', res.data.data)
        return res
      } catch (e) {
        throw new Error(e)
      }
    },
    async getHistoryData ({
      commit
    }, data) {
      try {
        var res = await getHistorydeviceLog(data)
        commit('setHistoryData', res.data.data)
        return res
      } catch (e) {
        throw new Error(e)
      }
    }
  }
}

export default syzModules
